<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8" />
    <title>角色成员管理</title>
    <script th:src="@{/plugin/jquery/jquery-1.9.0.min.js}" type="text/javascript"></script>
    <link th:href="@{/plugin/ligerUI/skins/Aqua/css/ligerui-all.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{/plugin/ligerUI/skins/Gray/css/all.css}" rel="stylesheet"/>
    <link th:href="@{/plugin/ligerUI/skins/ligerui-icons.css}" rel="stylesheet" type="text/css" />

    <script th:src="@{/plugin/ligerUI/js/core/base.js}" type="text/javascript"></script>

    <script th:src="@{/plugin/ligerUI/js/ligerui.all.js}" type="text/javascript"></script>
    <script th:src="@{/plugin/ligerUI/js/core/init-obj.js}" type="text/javascript"></script>
    <script th:inline="javascript">
        /*<![CDATA[*/
        /*]]>*/
        var productId=null;
        var navtab = null;
        var tree8 =null;
        $(function () {
            $("#layout1").ligerLayout({leftWidth: 150});
            search();
            tree8= $("#tree8").ligerTree({
                url:'/sec/org/tree',
                ajaxType:'post',
                checkbox: false,
                parentIcon: 'folder',
                childIcon: 'leaf' ,
                slide: false, //是否显示动画
                nodeWidth: 100,
                idFieldName: 'id',
                textFieldName:'name' ,
                onSelect: function (node)
                {
                    $('#orgId').val(node.data.id);
                    search()
                },
                onError:function(node){
                    $.ligerDialog.error('组织列表加载失败!');
                }
            });
        })
        function toolbarclick(item)
        {
            var roleId = $('#id').val()
            var obj = dataGrid.getSelecteds();
            if(item=='add') {
                if(obj.length>0){
                    var userIds = '';
                    /*<![CDATA[*/
                    for (var i = 0; i < obj.length - 1; i++) {
                        userIds += obj[i].id + ",";
                    }
                    userIds += obj[obj.length - 1].id;
                    $.ajax({
                        type: 'POST',
                        url: 'add?userId='+userIds+'&roleId='+roleId,
                        success: function(data){
                            parent.callBack();
                        },
                        error:function (data) {
                            alert(data);
                        }
                    });
                } else {
                    $.ligerDialog.question("请选择要添加的成员");
                }
            }
        }

        function callBack()
        {
            navtab.removeTabItem('add');
            navtab.removeTabItem('update');
            dataGrid.reload();
        }
        function search() {
            var data = $("#searchFrom").serializeArray();
            loadDataAptitude(data);
        }
        function reset() {
            $("#searchFrom")[0].reset();
        }
        var dataGrid =null;
        //加载角色列表
        function loadDataAptitude(data){
            dataGrid   =$("#maingrid").ligerGrid({
                height: '100%',
                columns: [
                    { display: '成员账户', name: 'account', minWidth: 180 },
                    { display: '成员名称', name: 'userName',minWidth: 180 },
                    { display: '成员电话', name: 'mobile', minWidth: 180 },
                    { display: '成员邮箱', name: 'email', minWidth: 180 },
                ],
                /*toolbar: {
                    items: [
                        { text: '保存数据', click: itemclick, icon: 'add',id:'add' },
                    ]
                },*/
                parms:data,
                checkbox:true,
                autoFilter: true,
                dataAction:"local",
                url:"userList",
                usePager:true,
                pageSize:"20",//分页页面大小
                pageSizeOptions:[10,20,30]//可指定每页页面大小
            });
            var s=  $(".l-panel-topbarinner .l-toolbar-item:last").find(".l-icon-search2");
            if(s.length==1){
                $(".l-panel-topbarinner .l-toolbar-item:last").remove();
            }
        }
        var tabs =null
    </script>
</head>
<body style="padding:4px">
<div id="layout1">
    <div  position="left" title="组织树">
        <ul id="tree8"></ul>
    </div>
    <div  position="center" title="成员详细信息">
                <form id="searchFrom">
                    <!--<div>
                        <label>成员名称</label>

                        <input name="type" type="button" onclick="search()" value="搜索"/>
                        <input name="type" type="button" onclick="reset()" value="重置"/>
                    </div>-->
                    <input  id="orgId"  name="orgId" type="hidden" value=""/>
                    <input  id="id"  name="id" type="hidden" th:value="${id}"/>
                </form>
                <div>
                    <span>当前操作角色：</span><span style="color: red" th:text="${roleName}"></span>
                </div>
                <div>
                    <a href="javascript:toolbarclick('add')">添加成员</a>
                </div>
                <div class="l-clear"></div>
                <div  id="maingrid"></div>
            </div>
        </div>
</body>
</html>